var oxmonth = document.getElementById('calendar-month');
var firstWeek = document.getElementById('weekday');
var everyday = document.getElementsByClassName('day');
//获取完整的日期
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;

//var mydate =(month<10 ? "0"+month:month).toString();
//console.log(mydate);
oxmonth.innerText = new Date().toDateString().split(" ")[1];

function all() {
	for (var i = 0; i < 42; i++) {
		document.getElementsByClassName('day')[i].innerText = '';
	} //第一件事，清空所有的装日期的格子

	var d = new Date();
	//获取选中的月份的时间信息d
	//console.log(d);


	var day1 = d.getDay() - 1; //获取选中月份的第一天是星期几
	//console.log(day1);
	firstWeek.getElementsByClassName('day')[day1].innerText = '1';
	everyday[day1 + 1].innerText = '2';

	//获取最后一天的日期：

	var month = d.getMonth();
	var fullyear = d.getFullYear();
	var d1 = new Date(fullyear, month + 1, 0);
	//console.log(d1);
	var lastday = d1.getDate();
	//console.log(lastday);

	//将除了第一天以外的其他日期填写到对应的位置
	for (var j = day1 + 1; j < lastday + day1; j++) {
		everyday[j].innerText = j - day1 + 1;
	}
	
	

}
all();

//每隔1秒刷新一次
//setInterval(all, 1000);

